package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: ShopController
 * Package: IntelliJ IDEA
 *
 * @author 张文豪
 * @description
 * @date 2023/8/17 9:13
 */
@RestController("userShopController")
@Api("营业状态相关接口")
@Slf4j
@RequestMapping("/user/shop")
public class ShopController {
    @Autowired
    private RedisTemplate redisTemplate;
    public static final String key = "SHOP_STATUS";

    /**
     * 获取店铺营业状态
     * @author: zwh
     * @date:
     * @param
     * @return:
     */

    @ApiOperation("获取店铺营业状态")
    @GetMapping("/status")
    public Result<Integer> getStatus(){
        Integer integer = (Integer) redisTemplate.opsForValue().get(key);
        log.info("获取到的店铺状态为：{}",integer == 1 ? "营业中" : "打样中");
        return Result.success(integer);
    }

}
